package net.funwoo.pandago;

import android.app.Application;

import com.squareup.picasso.Picasso;

import cn.smssdk.SMSSDK;
import de.greenrobot.event.EventBus;

/**
 * Created by Bob Peng on 2015/5/6.
 */
public class AppApplication extends Application {
    private static AppApplication sApplication;

    private int mId;

    public static AppApplication getInstance() {
        return sApplication;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        sApplication = this;

        // init event bus
        EventBus.builder()
                .logNoSubscriberMessages(false)
                .sendNoSubscriberEvent(false)
                .installDefaultEventBus();

        // init picasso
        Picasso.setSingletonInstance(new Picasso.Builder(this).build());

        // init sms sdk
        SMSSDK.initSDK(this, AppConfig.SMS_APP_KEY, AppConfig.SMS_APP_SECRET);

        initData();
    }

    private void initData() {
        // TODO
    }

    public void setUserId(int id) {
        if (mId != id) {
            AppConfig.putInt(AppConfig.KEY_USER_ID, id);
        }

        mId = id;
    }

}
